<%@ page language="java" contentType="text/html;charset=UTF-8" %>
<%@ include file="/static/include/taglib.jsp" %>
<!DOCTYPE html >
<html>
<head>
    <meta name="viewport" content="width=device-width"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>后台管理--模板编辑</title>
    <link href="${ctxStatic}/layui/css/layui.css" rel="stylesheet"/>
    <link href="${ctxStatic}/css/kpiuitanchu.css" rel="stylesheet"/>
    <script src="${ctxStatic}/js/jquery-1.8.3.min.js?v=2.0" type="text/javascript"></script>
    <script src="${ctxStatic}/layui/layui.all.js" type="text/javascript"></script>
    <style>
        .data {
            display: none
        }

    </style>
</head>
<body>
<div class="tanchucontent">
    <form class="layui-form" id="formedit" name="formedit" action="add_templateindex" method="post"
          target="d41d8cd98f00b204e9800998ecf8427e">
        <iframe name="d41d8cd98f00b204e9800998ecf8427e" src="about:blank" style="display:none;"></iframe>
        <table>
            <tr>
                <td class="td_right">类型：</td>
                <td>
                    <c:if test="${entity.assindextype == 0}">
                        <input type="radio" name="assindextype" value="0" title="内容"
                               checked="" lay-filter="datatype">
                        <input type="radio" lay-filter="datatype" name="assindextype" value="1" title="指标">
                    </c:if>
                    <c:if test="${entity.assindextype == 1}">
                        <input type="radio" lay-filter="datatype" name="assindextype" value="0" title="内容">
                        <input type="radio" lay-filter="datatype" name="assindextype" value="1" title="指标"
                               checked="">
                    </c:if>
                </td>
            </tr>
            <tr>
                <td class="td_right">上级：</td>
                <td>
                    <select name="parentid" lay-verify="required">
                        <option value="0">请选择上级</option>
                        <c:forEach var="item" items="${lst}">
                            <c:if test="${entity.parentid == item.assindexid}">
                                <option selected="selected" value="${item.assindexid}">${item.uasscontent}</option>
                            </c:if>
                            <c:if test="${entity.parentid != item.assindexid}">
                                <option value="${item.assindexid}">${item.uasscontent}</option>
                            </c:if>

                        </c:forEach>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="td_right">内容：</td>
                <td>
                    <c:if test="${entity.assindextype == 0}">
                        <input type="text" name="uasscontent" lay-verify="required" autocomplete="off"
                               class="layui-input" value="${entity.uasscontent }">
                    </c:if>
                    <c:if test="${entity.assindextype == 1}">
                        <input type="text" name="uasscontent" lay-verify="required" autocomplete="off"
                               class="layui-input" value="${entity.uassingredients }">
                    </c:if>

                </td>
            </tr>
            <%--<tr>--%>
            <%--<td class="td_right">分数：</td>--%>
            <%--<td>--%>
            <%--<input type="text" name="score" lay-verify="required|number" autocomplete="off" class="layui-input" value="${entity.score }" >--%>
            <%--</td>--%>
            <%--</tr>--%>
            <tr>
                <td class="td_right">评价标准：</td>
                <td>
                    <textarea class="layui-textarea" name="evaluationstandard">${entity.evaluationstandard }</textarea>
                </td>
            </tr>

            <tr class="data">
                <td class="td_right">属性：</td>
                <td>
                    <select lay-filter="test" name="datatype"  id="dataType">



                        <c:forEach var="item" items="${items}">
                            <c:if test="${item.codedes == entity.datatype}">
                                <option selected="selected" value="${item.codedes}">${item.codename}</option>
                            </c:if>
                            <c:if test="${item.codedes != entity.datatype}">
                                <option value="${item.codedes}">${item.codename}</option>
                            </c:if>
                        </c:forEach>



                    </select>
                </td>
            </tr>

            <%--<tr class="data" style="display: none">--%>
                <%--<td class="td_right"></td>--%>
                <%--<td>--%>
                    <%--<input id="dataValue" type="text" name="datavalue" class="layui-input" value="${entity.datavalue }">--%>

                <%--</td>--%>
            <%--</tr>--%>
            <tr>
                <td colspan="2" style="text-align: center;padding-top:10px">
                    <button class="button" lay-submit="" lay-filter="demo1" id="btnsave">保存</button>
                    <input type="button" value="关闭" class="button" onclick="top.CloseOpenWindow()"/>
                </td>
            </tr>
        </table>

        <input type="hidden" name="assindexid" id="assindexid" value="${entity.assindexid }"/>

        <input type="hidden" id="hiddatatype" value="${entity.assindextype}">
    </form>

    <script>

        $(function () {

            if ($('#hiddatatype').val() == 1)
                $('.data').show();
        })


        layui.use('form', function () {
            var form = layui.form;

            form.on('radio(datatype)', function (data) {
                if (data.value == 1) {
                    $('.data').show()
                } else {
                    $('.data').hide();
                }
            });
            form.on('submit(demo1)', function (data) {
                if (data.field.assindextype == 1) {
                    if (data.field.parentid == 0) {
                        alert('请选择上级');
                        return false;
                    }
                }
                else {
                    if (data.field.parentid != 0) {
                        alert('内容项不需要上级');
                        return false;
                    }
                }
                return true;
            })

            form.on('select(test)', function (data) {
                if (data.value == 1) {
                    $('#dataValue').removeAttr("disabled")
                } else {
                    $('#dataValue').attr('disabled', 'disabled');
                    $('#dataValue').val('');

                }
            });
            form.render();
        });

        function CloseDialog(result, msg) {
            top.frames["iframe"].vWorkJxIndex.addresult(result, msg);
        }
    </script>
</div>
</body>
</html>